$(function () {

    init();

});

var init = function () {
    var html = " <!--头部-->" +
        "    <div class='header'>" +
        "        <div class='head-nav'>" +
        "            <div  class='logo' style=''>" +
        "                <img class='app_app_index' id='logo' src='../../app/static/images/basepage/logo.png'/>" +
        "            </div>" +
        "            <div class='head-nav-con clearFloat'>" +
        "                <ul>" +
        "                    <li class='drop-down'>" +
        "                        <a class='module-item item' id='module-btn-microdata' title='宏观数据' data-value='microdata'>" +
        "                            <div class='module_img'>" +
        "                                <img src='../../app/static/lib/images/first/icon-jc.png'/>" +
        "                                <span>宏观数据管理</span>" +
        "                            </div>" +
        "                        </a>" +
        "                        <ul class='drop-down-content'>" +
        "                            <li><a class='app_macro_economic disabled' href='#'>宏观经济结构分析</a></li>" +

        "                            <li><a class='app_new_town_industry disabled' href='#'>新区产业结构分析</a></li>" +
        // "                            <li><a class='app_macro_iden disabled' href='#'>宏观经济指标及构成</a></li>" +
        "                            <li><a class='app_macro_search disabled' href='#'>宏观数据查询</a></li>" +
        "                            <li><a class='app_macro_form disabled' href='#'>报表中心</a></li>" +
        "                        </ul>" +
        "                    </li>" +

        "                    <li class='drop-down'>" +
        "                        <a class='module-item item' id='module-btn-publicService' title='综合数据' data-value='gallery'>" +
        "                            <div class='module_img'>" +
        "                                <img src='../../app/static/lib/images/first/icon-tj.png'/>" +
        "                                <span>企业查询分析</span>" +
        "                            </div>" +

        "                        </a>" +
        "                        <ul class='drop-down-content'>" +
        "                            <li><a class='app_enterprise_search disabled' href='#'>企业信息查询</a></li>" +
        "                            <li><a class='app_enterprise_framework disabled hide' href='#'>企业结构分析</a></li>" +
        "                            <li><a class='app_one_company_one_record disabled' href='#'>一企一档</a></li>" +
        "                            <li><a class='app_online_report disabled ' href='#'>联网直报</a></li>" +
        "                        </ul>" +
        "                    </li>" +
        "                    <li class='drop-down'>" +
        "                        <a class='module-item item' id='module-btn-themeSearch' title='项目建设管理' data-value='macrodata'>" +
        "                            <div class='module_img'>" +
        "                                <img src='../../app/static/lib/images/first/icon-zt.png'/>" +
        "                                <span>项目建设管理</span>" +
        "                            </div>" +
        "                        </a>" +
        "                        <ul class='drop-down-content'>" +
        "                            <li><a class='app_project_manage disabled' href='javascript:void(0);'>项目管理</a></li>" +
        "                            <li><a class='app_project_search disabled' href='#'>项目查询分析</a></li>" +
        "                            <li><a class='app_project_statistics disabled' href='#'>项目统计</a></li>" +
        "                        </ul>" +
        "                    </li>" +

        "                    <li class='drop-down'>" +
        "                        <a class='module-item item' id='module-btn-macrodata' title='目标进度' data-value='macrodata'>" +
        "                            <div class='module_img'>" +
        "                                <img src='../../app/static/lib/images/first/icon-sj.png'/>" +
        "                                <span>目标进度管理</span>" +
        "                            </div>" +
        "                        </a>" +
        "                        <ul class='drop-down-content'>" +
        "                            <li><a class='app_objective disabled' href='#'>目标制定</a></li>" +
        "                            <li><a class='app_target_check disabled' href='#'>目标考核</a></li>" +
        "                            <li><a class='app_target_monitor disabled' href='#'>进度监测</a></li>" +
        "                        </ul>" +
        "                    </li>" +

        "                    <li class='drop-down'>" +
        "                        <a class='module-item item' id='module-btn-visual' title='经济作战地图' data-value='visual'>" +
        "                            <div class='module_img'>" +
        "                                <img src='../../app/static/lib/images/first/icon-zh.png'/>" +
        "                                <span>经济作战地图</span>" +
        "                            </div>" +
        "                        </a>" +
        "                        <ul class='drop-down-content'>" +
        "                            <li><a class='app_enterprise_space_search disabled' href='#'>企业空间查询分析</a></li>" +
        "                            <li><a class='app_gallery disabled' href='#'>可视化专题分析</a></li>" +
            "                            <li><a class='app_industry_chain disabled' href='javascript:void(0);'>产业链</a></li>" +
        "                        </ul>" +
        "                    </li>" +

        "                    <li class='drop-down'>" +
        "                        <a class='module-item item' id='module-btn-bulletinfolder' title='信息管理' data-value='bulletinfolder'>" +
        "                            <div class='module_img'>" +
        "                                <img src='../../app/static/lib/images/first/icon-np.png'/>" +
        "                                <span>信息管理</span>" +
        "                            </div>" +
        "                        </a>" +
        "                        <ul class='drop-down-content'>" +
        "                            <li><a class='app_result_manage disabled' href='#'>成果管理</a></li>" +
        "                            <li><a class='app_info_push disabled' href='#'>信息推送</a></li>" +
        "                        </ul>" +
        "                    </li>" +
        "                </ul>" +
        "            </div>" +

        "  <div class='two wide column' style='float: right;display: inline-block;text-align: right;line-height: 50px'>" +
        "        <div class='item' id='user'>" +
        "            <div class='ui floating dropdown'><img class='' src='../static/images/admin.png'><span id='userName'></span> <i class='dropdown icon'></i>" +
        "                <div class='menu usermenu'>" +
        "                    <div class='item' id='sys-btn-logout'>注销</div>" +
        "                    <div class='item app_BI_tool disabled' >BI工具</div>" +
        "                    <div class='item app_drapt_tool disabled' >制图工具</div>" +
        "                    <div class='item app_data_manage disabled' >业务数据管理</div>" +
        "                    <div class='item app_system_manage disabled' >系统管理</div>" +
        "                </div>" +
        "            </div>" +
        "        </div>" +
        "    </div>" +


        "        </div>" +
        "    </div>" +
        " <div class='header_div'>" +
        "<span class='header_title'></span>"+
        "</div>";


    $(".top_div").html(html);

    addCss("../../app/static/lib/semantic/css/semantic.css");
    addCss("../../app/static/lib/page/SGIS.Base.css");

    addCss("../../app/static/css/top.css");
    addCss("../../app/static/css/index.css");

    addScript("../../app/static/lib/semantic/javascript/semantic.min.js");
    addScript("../../app/static/lib/common/SGIS.Base.js");
    addScript("../../app/static/js/address.js");

    addScript("../../app/static/lib/login.js");

};

function addScript(url) {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;
    $('body').append(script);
}

function addCss(url) {
    var css = '<link rel="stylesheet" href="' + url + '"/>';
    $('head').append(css);
}
/***添加导航栏面包屑***/
function addNavBread(){
    var href = window.location.href;
    var page = href.split('/');
    var curPage = page[page.length-1];
    var nav = '';
    switch (curPage) {
        case 'dataBoard': nav ='宏观数据管理 / 宏观经济结构分析';break;
        case 'dataBoard#': nav ='宏观数据管理 / 宏观经济结构分析';break;
        case 'newTownIndustry':nav ='宏观数据管理 / 新区产业结构分析';break;
        case 'newTownIndustry#':nav ='宏观数据管理 / 新区产业结构分析';break;
        case 'idenForm':nav ='宏观数据管理 / 宏观经济指标及构成';break;
        case 'idenForm#':nav ='宏观数据管理 / 宏观经济指标及构成';break;
        case 'macro' :nav ='宏观数据管理 / 宏观数据查询';break;
        case 'macro#':nav ='宏观数据管理 / 宏观数据查询';break;
        case 'report_center':nav ='宏观数据管理 / 报表中心';break;
        case 'report_center#':nav ='宏观数据管理 / 报表中心';break;
        case 'targetManagement':nav ='目标进度管理 / 进度检测';break;
        case  'targetManagement#':nav ='目标进度管理 / 进度检测';break;
        case  'enterprise_search#':nav ='企业查询分析 / 企业信息查询';break;
        case 'enterprise_search':nav ='企业查询分析 / 企业信息查询';
        case 'enterpriseVolum' :nav ='企业查询分析 / 一企一档';break;
        case 'enterpriseVolum#':nav ='企业查询分析 / 一企一档';break;
        case 'base.html':nav ='经济作战地图 / 企业空间查询分析';break;
        case 'industry_chain' :nav ='经济作战地图 / 产业链';break;
        case 'industry_chain#':nav ='经济作战地图 / 产业链';break;
        case 'project_manage':nav ='项目建设管理 / 项目管理';break;
        case 'inDevelopment':nav ='';break;
        case "iden": nav ='目标进度管理 / 目标制定';break;
        case "iden#": nav ='目标进度管理 / 目标制定';break;
        default:break;
    }

    var is_has_gallery = href.indexOf('gallery2.1/http/');
    if(is_has_gallery!=-1){
        nav ='经济作战地图 / 可视化专题分析'
    }
    var is_has_web_base = href.indexOf('/main/base.html');
    if(is_has_web_base!=-1){
        nav ='经济作战地图 / 企业空间查询分析'
    }

    $('.top_div .header_div>.header_title').html(nav);
    setTimeout(function(){
        $('.top_div .header_div>.header_title').html(nav);
    },1000)
};
$(document).ready(function(){
    /*******添加导航栏面包屑配置**/
    addNavBread();
    /***三方应用循环****/
    Object.keys(dsf).forEach(function(key){
        try{
            var el = document.getElementById(key)
            el.src = dsf[key];
        }catch(err){}

    });

    setEnterpriseSearchIframeSrc();
})



/**
 * 页面加载之前给 引用的 帆软报表 iframe src赋值
 */
function setEnterpriseSearchIframeSrc() {
    $("#enterprise_search_id").attr("src",window.fanruan.enterprise_search_path);
}

